#!/usr/bin/python
# -*- coding: utf-8 -*-

class TagInfo:
    def __init__(self, tag, count):
        self.tag = tag
        self.count = count

file = open('all_tags.lower', 'r')
dict = {}
for tag in file.readlines():
    tag = tag.rstrip()
    if dict.has_key(tag):
        dict[tag] = dict[tag] + 1
    else:
        dict[tag] = 1

sum = 0
cnt = 0
tag_info = []
for key in dict:
    tag_info.append(TagInfo(key, dict[key]))
    if dict[key] >= 10:
        sum = sum + dict[key]
        cnt = cnt + 1
print sum, cnt
tag_info.sort(lambda t1, t2: t2.count - t1.count)

out = open('tag.stat', 'w')
for data in tag_info:
    out.write(data.tag + ': ' + str(data.count) + '\n')
out.close()
file.close()
